// ===============================================
// app_theme_default
//
// Create by Will on 21/8/2023 16:59
// Copyright @xigou.All rights reserved.
// ===============================================

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'app_default_style.dart';

// import '../app_default_style.dart';

/// 主题
class AppThemeDefault {
  AppThemeDefault._internal();

  /// 浅色主题
  static final ThemeData lightTheme = ThemeData.light().copyWith(
    brightness: Brightness.light,
    // 文字
    // textTheme: TextTheme(
    //   displayLarge: TextStyle(color: Colors.black, fontSize: 14.sp),
    //   displayMedium: TextStyle(color: Colors.black, fontSize: 14.sp),
    //   displaySmall: TextStyle(color: Colors.black, fontSize: 14.sp),
    //   bodyLarge: TextStyle(color: Colors.black, fontSize: 14.sp),
    //   bodyMedium: TextStyle(color: Colors.black, fontSize: 14.sp),
    //   bodySmall: TextStyle(color: Colors.black, fontSize: 14.sp),
    // ),
    // 主颜色
    primaryColor: AppStyle.primaryColor,
    // scaffold背景颜色
    scaffoldBackgroundColor: AppStyle.scaffoldBackgroundColor,
    // bottomNavigationBar
    bottomNavigationBarTheme: const BottomNavigationBarThemeData(
      backgroundColor: Colors.white,
    ),
    // TabBar
    tabBarTheme: TabBarThemeData(
      indicator: const BoxDecoration(),
      indicatorColor: Colors.transparent,
      dividerColor: Colors.transparent,
      dividerHeight: 0,
      labelColor: Colors.black,
      labelPadding: EdgeInsets.symmetric(horizontal: AppStyle.padding),
      labelStyle: TextStyle(
        color: Colors.black,
        fontSize: 16.sp,
        fontWeight: FontWeight.bold,
      ),
      unselectedLabelColor: Colors.black.withOpacity(0.5),
      unselectedLabelStyle: TextStyle(
        color: Colors.black.withOpacity(0.5),
        fontSize: 16.sp,
      ),
      tabAlignment: TabAlignment.center,
      overlayColor: WidgetStateProperty.all(Colors.transparent),
    ),
    // // 回弹波浪颜色
    // primarySwatch: const MaterialColor(
    //   0xFF545454,
    //   <int, Color>{
    //     50: Color(0xFF545454),
    //     100: Color(0xFF545454),
    //     200: Color(0xFF545454),
    //     300: Color(0xFF545454),
    //     400: Color(0xFF545454),
    //     500: Color(0xFF545454),
    //     600: Color(0xFF545454),
    //     700: Color(0xFF545454),
    //     800: Color(0xFF545454),
    //     900: Color(0xFF545454),
    //   },
    // ),
    // 点击时水波颜色
    splashColor: Colors.transparent,
    // 点击时背景高亮颜色
    highlightColor: Colors.transparent,
    // Card
    cardColor: Colors.white,
    // bottomSheet
    bottomSheetTheme:
        const BottomSheetThemeData(modalBackgroundColor: Color(0xFFF6F8FA)),
    // Radio
    radioTheme: RadioThemeData(
      // fillColor: MaterialStateProperty.all(const Color(0xFF111315)),
      // overlayColor: MaterialStateProperty.all(const Color(0xFF111315)),
      fillColor: WidgetStateProperty.all(AppStyle.primaryColor),
      overlayColor: WidgetStateProperty.all(AppStyle.primaryColor),
    ),
    iconTheme: const IconThemeData(
      color: Color.fromRGBO(153, 153, 153, 1),
    ),
    visualDensity: VisualDensity.adaptivePlatformDensity,
    appBarTheme: const AppBarTheme(
      backgroundColor: AppStyle.appBarThemeBackgroundColor,
      systemOverlayStyle: SystemUiOverlayStyle(
        // statusBarColor: Colors.transparent,
        // statusBarIconBrightness: Brightness.light,

        systemNavigationBarColor: Colors.transparent,
        statusBarColor: Colors.transparent, //设置为透明
        systemNavigationBarIconBrightness: Brightness.light,
        statusBarIconBrightness: Brightness.light,
        statusBarBrightness: Brightness.dark,
      ),
      elevation: 0,
      toolbarHeight: 44,
    ),
    dividerColor: AppStyle.borderColor,
    dividerTheme: DividerThemeData(
      color: AppStyle.borderColor,
      //indent: 28.w, //全局一般都是0，特殊的自己加
      endIndent: 0.w,
    ),
    unselectedWidgetColor: AppStyle.primaryColor,
    platform: TargetPlatform.android,
    // useMaterial3: false,
    colorScheme: const ColorScheme.light(
      secondary: AppStyle.primaryColor,
      surface: Colors.transparent,
    ),

    inputDecorationTheme: InputDecorationTheme(
      hintStyle: TextStyle(
        color: AppStyle.editHint, // 设置hint文本的颜色
        // fontStyle: FontStyle.italic, // 设置hint文本的样式
        fontSize: 14.sp,
      ),

      border: const UnderlineInputBorder(
        ///用来配置边框的样式
        borderSide: BorderSide(
          ///设置边框的颜色
          color: AppStyle.eee,
        ),
        // borderRadius: BorderRadius.circular(17.w),
      ),

      ///设置输入框可编辑时的边框样式
      enabledBorder: const UnderlineInputBorder(
        ///用来配置边框的样式
        borderSide: BorderSide(
          ///设置边框的颜色
          color: AppStyle.eee,
        ),
        // borderRadius: BorderRadius.circular(17.w),
      ),

      ///用来配置输入框获取焦点时的颜色
      focusedBorder: const UnderlineInputBorder(
        ///用来配置边框的样式
        borderSide: BorderSide(
          ///设置边框的颜色
          color: AppStyle.primaryColor,
        ),
        // borderRadius: BorderRadius.circular(17.w),
      ),
    ),

    hoverColor: AppStyle.primaryColor,
  );

  /// 深色主题
  static final ThemeData darkTheme = ThemeData.dark().copyWith(
    brightness: Brightness.dark,
    // 文字
    // textTheme: TextTheme(
    //   displayLarge: TextStyle(color: Colors.white, fontSize: 14.sp),
    //   displayMedium: TextStyle(color: Colors.white, fontSize: 14.sp),
    //   displaySmall: TextStyle(color: Colors.white, fontSize: 14.sp),
    //   bodyLarge: TextStyle(color: Colors.white, fontSize: 14.sp),
    //   bodyMedium: TextStyle(color: Colors.white, fontSize: 14.sp),
    //   bodySmall: TextStyle(color: Colors.white, fontSize: 14.sp),
    // ),
    // 主颜色
    primaryColor: AppStyle.primaryColor,
    // scaffold背景颜色
    scaffoldBackgroundColor: Colors.black,
    // bottomNavigationBar
    bottomNavigationBarTheme: const BottomNavigationBarThemeData(
      backgroundColor: Color(0xFF1A1D1F),
    ),
    // TabBar
    tabBarTheme: TabBarThemeData(
      indicator: const BoxDecoration(),
      indicatorColor: Colors.transparent,
      dividerColor: Colors.transparent,
      dividerHeight: 0,
      labelColor: Colors.white,
      labelPadding: EdgeInsets.symmetric(horizontal: AppStyle.padding),
      labelStyle: TextStyle(
        color: Colors.white,
        fontSize: 16.sp,
        fontWeight: FontWeight.bold,
      ),
      unselectedLabelColor: Colors.white.withOpacity(0.5),
      unselectedLabelStyle: TextStyle(
        color: Colors.white.withOpacity(0.5),
        fontSize: 16.sp,
      ),
      tabAlignment: TabAlignment.center,
      overlayColor: WidgetStateProperty.all(Colors.transparent),
    ),
    // // 回弹波浪颜色
    // primarySwatch: const MaterialColor(
    //   0xFF545454,
    //   <int, Color>{
    //     50: Color(0xFF545454),
    //     100: Color(0xFF545454),
    //     200: Color(0xFF545454),
    //     300: Color(0xFF545454),
    //     400: Color(0xFF545454),
    //     500: Color(0xFF545454),
    //     600: Color(0xFF545454),
    //     700: Color(0xFF545454),
    //     800: Color(0xFF545454),
    //     900: Color(0xFF545454),
    //   },
    // ),
    // 点击时水波颜色
    splashColor: Colors.transparent,
    // 点击时背景高亮颜色
    highlightColor: Colors.transparent,
    // Card
    cardColor: const Color(0xFF202427),
    // bottomSheet
    bottomSheetTheme:
        const BottomSheetThemeData(modalBackgroundColor: Color(0xFF111315)),
    // Radio
    radioTheme: RadioThemeData(
      // fillColor: MaterialStateProperty.all(const Color(0xFFEFEFEF)),
      // overlayColor: MaterialStateProperty.all(const Color(0xFFEFEFEF)),
      fillColor: WidgetStateProperty.all(AppStyle.primaryColor),
      overlayColor: WidgetStateProperty.all(AppStyle.primaryColor),
    ),

    visualDensity: VisualDensity.adaptivePlatformDensity,
    appBarTheme: const AppBarTheme(
      backgroundColor: AppStyle.appBarThemeBackgroundColor,
      systemOverlayStyle: SystemUiOverlayStyle(
        // statusBarColor: Colors.transparent,
        // statusBarIconBrightness: Brightness.dark,

        systemNavigationBarColor: Colors.transparent,
        statusBarColor: Colors.transparent, //设置为透明
        systemNavigationBarIconBrightness: Brightness.light,
        statusBarIconBrightness: Brightness.dark,
        statusBarBrightness: Brightness.light,
      ),
      elevation: 0,
      toolbarHeight: 44,
    ),
    dividerColor: AppStyle.borderColor,
    dividerTheme: DividerThemeData(
      color: Colors.black12,
      //indent: 28.w, //全局一般都是0，特殊的自己加
      endIndent: 0.w,
    ),
    // unselectedWidgetColor: AppStyle.primaryColorDark,
    platform: TargetPlatform.android,
    // useMaterial3: false,
    colorScheme: const ColorScheme.dark(
      secondary: AppStyle.primaryColor,
      surface: Colors.transparent,
    ),

    inputDecorationTheme: InputDecorationTheme(
      hintStyle: TextStyle(
        color: AppStyle.editHint, // 设置hint文本的颜色
        // fontStyle: FontStyle.italic, // 设置hint文本的样式
        fontSize: 14.sp,
      ),
      border: const UnderlineInputBorder(
        ///用来配置边框的样式
        borderSide: BorderSide(
          ///设置边框的颜色
          color: AppStyle.eee,
        ),
        // borderRadius: BorderRadius.circular(17.w),
      ),

      ///设置输入框可编辑时的边框样式
      enabledBorder: const UnderlineInputBorder(
        ///用来配置边框的样式
        borderSide: BorderSide(
          ///设置边框的颜色
          color: AppStyle.primaryColor,
        ),
        // borderRadius: BorderRadius.circular(17.w),
      ),

      ///用来配置输入框获取焦点时的颜色
      focusedBorder: const UnderlineInputBorder(
        ///用来配置边框的样式
        borderSide: BorderSide(
          ///设置边框的颜色
          color: AppStyle.primaryColor,
        ),
        // borderRadius: BorderRadius.circular(17.w),
      ),
    ),

    hoverColor: AppStyle.primaryColor,
  );

  ///默认的苹果主题 因为采用苹果主题设计比较多 所以采用这样的方式
  static CupertinoThemeData cupertinoTheme({
    required Brightness brightness,
  }) {
    return CupertinoThemeData(
      brightness: brightness,
      primaryColor: AppStyle.primaryColor,
      barBackgroundColor: const CupertinoDynamicColor.withBrightness(
        color: Colors.white,
        darkColor: Colors.black,
      ),
      primaryContrastingColor: const Color(0xFFF788A7),
      scaffoldBackgroundColor: AppStyle.scaffoldBackgroundColor,
      applyThemeToAll: true,
      textTheme: CupertinoTextThemeData(
        textStyle: TextStyle(
          fontSize: 14.sp,
          color: AppStyle.color777,
        ),
        actionTextStyle: TextStyle(
          fontSize: 14.sp,
          color: AppStyle.color777,
        ),
        tabLabelTextStyle: TextStyle(
          fontSize: 14.sp,
          color: AppStyle.color777,
        ),
        navTitleTextStyle: TextStyle(
          color: AppStyle.navTitleTextColor,
          fontSize: 16.sp,
          fontWeight: FontWeight.bold,
        ),
        navLargeTitleTextStyle: TextStyle(
          color: AppStyle.navTitleTextColor,
          fontSize: 16.sp,
        ),
        navActionTextStyle: TextStyle(
          color: AppStyle.navTitleTextColor,
          fontSize: 16.sp,
        ),
      ),
    );
  }
}
